Using locales

Kanzi uses locale as an ID to select the resources associated with a language and location. If you do not define the resources for a locale, Kanzi uses the resources set in the default locale.

Learn how to localize your Kanzi applications by completing the localization tutorial. See Tutorial: Localize your application.

Setting the application locale

Use the Locale property in the Screen node to set which locale your application uses.

For example:

Creating locale packs

A locale pack is a .kzb file that contains only the resources of a specific locale. Using Kanzi Engine API you can load the application resources used by a certain locale only when you need them, and unload the resources that the application does not need. That way only the resources used by the current locale occupy the device memory.

When you want to export a resource that is used by a locale pack to the main project .kzb, in the Library select the resource and in the Properties add and enable the Is Used By Code property. All resources that have Is Used By Code property enabled are exported only to the main project .kzb file and not to any locale packs that use them.

To create a locale pack:

  1. In the Library > Localization add to the localization tables the resources used by the locale you want to add to your Kanzi application in a locale pack.
  2. In the Library > Localization double-click any localization table and in the Localization Editor click next to the locale name the resources of which you want to export in a locale pack.
  3. In Kanzi Studio select File > Export KZB > Export Locale KZBs. This command:

    Tip If you want to export the entire Kanzi Studio project to a single .kzb file, including the resources of locales you mark as locale packs, select File > Export KZB > Export KZB Binary.

  4. Use the Kanzi Engine API to load the locale pack in your Kanzi application. See Tutorial: Localize your application.

Adding a locale manually

Kanzi uses locale as an ID to select the resources associated with a language and location. If you do not define the resources for a locale, Kanzi uses the resources set in the default locale.

When you import a .po file, Kanzi automatically adds a locale set in that .po file, if the locale with the same name does not already exist.

To add a locale manually:

  1. In the Library > Localization double-click any localization table.
    Kanzi Studio opens the localization table in the Localization Editor.
  2. In the Localization Editor click , select the locale from the drop-down list, and click OK.
    Kanzi Studio adds the locale to all localization tables in your project.

Changing the name of an existing locale

To change the name of an existing locale:

  1. In the Library > Localization in any localization table, right-click the header of the locale you want to rename, and select Rename.
  2. Select the new locale name from the drop-down list and click OK.

See also

Localizing applications

Tutorial: Localize your application tutorial

Localization